package exception;
//Finally 相关面试题
public class FinallyDemo3 {
    public static void main(String[] args) {
        System.out.println(
                dosome("0")+","+dosome(null)+","+dosome("")
        );

    }

    public static int dosome(String str){
        try {
            return str.charAt(0)-'0'; //输出结果为0 但走try 必须走finally 返回3 覆盖原结果
        } catch (NullPointerException e) {
            return 1;                  //null:返回结果为1  走finally覆盖原结果
        }catch (Exception e){         //空穿：返回结果为2    走finally覆盖原结果
            return 2;
        }
        finally {
            return 3;
        }
    }
}
